/*
 *  LLTimeManager.cpp
 *
 *
 *  Created by Alexander Trutchenko on 11/02/12.
 *  Copyright 2012 Free Team. All rights reserved.
 *
 */

#include "lid_lib/src/time_managment/LLTimeManager.h"

#include "lid_lib/src/data_managment/LLNotifier.h"

#include "lid_lib/src/config/LLConfig.h"
#include "lid_lib/src/config/LLKeys.h"

#include <Windows.h>


namespace lidlib {

////////////////////////////////////////////////////////
//
/** LLTimeManager
 *
 */
////////////////////////////////////////////////////////

unsigned int LLTimeManager::getSeconds() 
{
	SYSTEMTIME wtm;
	GetLocalTime(&wtm);
	return (unsigned int)wtm.wSecond;
}

unsigned int LLTimeManager::getMinutes() 
{
	SYSTEMTIME wtm;
	GetLocalTime(&wtm);
	return (unsigned int)wtm.wMinute;
}

unsigned int LLTimeManager::getHours() 
{
	SYSTEMTIME wtm;
	GetLocalTime(&wtm);
	return (unsigned int)wtm.wHour;
}

unsigned int LLTimeManager::getMonthDay() 
{
	SYSTEMTIME wtm;
	GetLocalTime(&wtm);
	return (unsigned int)wtm.wDay;
}

unsigned int LLTimeManager::getMonth() 
{
	SYSTEMTIME wtm;
	GetLocalTime(&wtm);
	return (unsigned int)wtm.wMonth;
}

unsigned int LLTimeManager::getYear() 
{
	SYSTEMTIME wtm;
	GetLocalTime(&wtm);
	return (unsigned int)wtm.wYear;
}

ELLWeekDay LLTimeManager::getWeekDay() 
{
	SYSTEMTIME wtm;
	GetLocalTime(&wtm);
	switch (wtm.wDayOfWeek)
	{
	case 0: return ell_wd_sunday;
	case 1: return ell_wd_monday;
	case 2: return ell_wd_tuesday;
	case 3: return ell_wd_wednesday;
	case 4: return ell_wd_thursday;
	case 5: return ell_wd_friday;
	case 6: return ell_wd_saturday;
	default: break;
	}
	return ell_wd_invalid;
}

////////////////////////////////////////////////////////
// Private interface

/*
	TIME_ZONE_INFORMATION timeZoneInformation;
	DWORD res = GetTimeZoneInformation(&timeZoneInformation);
	switch(res)
	{
		case TIME_ZONE_ID_UNKNOWN: break;
		case TIME_ZONE_ID_STANDARD: break;
		case TIME_ZONE_ID_DAYLIGHT: break;
	}
*/

void LLTimeManager::update(float dt) 
{
	SYSTEMTIME wtm;
	GetLocalTime(&wtm);

	ELLWeekDay wd = ell_wd_invalid;
	switch (wtm.wDayOfWeek)
	{
	case 0: wd = ell_wd_sunday; break;
	case 1: wd = ell_wd_monday; break;
	case 2: wd = ell_wd_tuesday; break;
	case 3: wd = ell_wd_wednesday; break;
	case 4: wd = ell_wd_thursday; break;
	case 5: wd = ell_wd_friday; break;
	case 6: wd = ell_wd_saturday; break;
	default: break;
	}

	compareTime((unsigned int)wtm.wSecond,
				(unsigned int)wtm.wMinute,
				(unsigned int)wtm.wHour,
				(unsigned int)wtm.wDay,
				(unsigned int)wtm.wMonth,
				(unsigned int)wtm.wYear,
				wd);

}

} // namespace lidlib
